package com.clh.seckill.controller;


import com.clh.seckill.pojo.Order;
import com.clh.seckill.pojo.SeckillOrder;
import com.clh.seckill.pojo.User;
import com.clh.seckill.service.IGoodsService;
import com.clh.seckill.service.IOrderService;
import com.clh.seckill.service.ISeckillGoodsService;
import com.clh.seckill.service.ISeckillOrderService;
import com.clh.seckill.vo.GoodsVo;
import com.clh.seckill.vo.RespBeanEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author clh
 * @since 2021-11-12
 */
@Controller
@RequestMapping("/seckillOrder")
public class SeckillOrderController {
    @Autowired
    ISeckillOrderService seckillOrderService;
    @Autowired
    IGoodsService goodsService;
    @Autowired
    IOrderService orderService;
    @RequestMapping("/toOrderDetail")
    public String toOrderDetail(User user, Long orderId, Model model){
        Order order = orderService.getById(orderId);
        if (null==order){
            model.addAttribute("errorMeg", RespBeanEnum.NOTORDER.getMessage());
            return "secKillFail";
        }
        GoodsVo goodsVo = goodsService.findGoodsById(order.getGoodsId());
        model.addAttribute("goods",goodsVo);
        model.addAttribute("order",order);
        return "orderDetail";
    }
}
